<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<html:header title="进销存系统"
             keywords=""
             description="">

    <style>
        .layuimini-logo img{
            border-radius: 50%;
        }
    </style>
    <style id="layuimini-bg-color">
    </style>
</html:header>
<body class="layui-layout-body layuimini-all">
<div class="layui-layout layui-layout-admin">

    <div class="layui-header header">
        <div class="layui-logo layuimini-logo"></div>

        <div class="layuimini-header-content">
            <a>
                <div class="layuimini-tool"><i title="展开" class="fa fa-outdent" data-side-fold="1"></i></div>
            </a>

            <!--电脑端头部菜单-->
            <ul class="layui-nav layui-layout-left layuimini-header-menu layuimini-menu-header-pc layuimini-pc-show">
            </ul>

            <!--手机端头部菜单-->
            <ul class="layui-nav layui-layout-left layuimini-header-menu layuimini-mobile-show">
                <li class="layui-nav-item">
                    <a href="javascript:;"><i class="fa fa-list-ul"></i> 选择模块</a>
                    <dl class="layui-nav-child layuimini-menu-header-mobile">
                    </dl>
                </li>
            </ul>

            <ul class="layui-nav layui-layout-right">

                <li class="layui-nav-item" lay-unselect>
                    <a href="javascript:;" data-refresh="刷新"><i class="fa fa-refresh"></i></a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a href="javascript:;" data-clear="清理" class="layuimini-clear"><i class="fa fa-trash-o"></i></a>
                </li>
                <li class="layui-nav-item mobile layui-hide-xs" lay-unselect>
                    <a href="javascript:;" data-check-screen="full"><i class="fa fa-arrows-alt"></i></a>
                </li>
                <li class="layui-nav-item layuimini-setting">
                    <a href="javascript:;">${userVo.name}</a>
                    <dl class="layui-nav-child">
                        <dd>
                            <a href="javascript:;" class="change-password">修改密码</a>
                        </dd>
                        <dd>
                            <hr>
                        </dd>
                        <dd>
                            <a href="javascript:;" class="login-out">退出登录</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item layuimini-select-bgcolor" lay-unselect>
                    <a href="javascript:;" data-bgcolor="配色方案"><i class="fa fa-ellipsis-v"></i></a>
                </li>
            </ul>
        </div>
    </div>

    <!--无限极左侧菜单-->
    <div class="layui-side layui-bg-black layuimini-menu-left">
    </div>

    <!--初始化加载层-->
    <div class="layuimini-loader">
        <div class="layuimini-loader-inner"></div>
    </div>

    <!--手机端遮罩层-->
    <div class="layuimini-make"></div>

    <!-- 移动导航 -->
    <div class="layuimini-site-mobile"><i class="layui-icon"></i></div>

    <div class="layui-body">

        <div class="layuimini-tab layui-tab-rollTool layui-tab" lay-filter="layuiminiTab" lay-allowclose="true">
            <ul class="layui-tab-title">
                <li class="layui-this" id="layuiminiHomeTabId" lay-id=""></li>
            </ul>
            <div class="layui-tab-control">
                <li class="layuimini-tab-roll-left layui-icon layui-icon-left"></li>
                <li class="layuimini-tab-roll-right layui-icon layui-icon-right"></li>
                <li class="layui-tab-tool layui-icon layui-icon-down">
                    <ul class="layui-nav close-box">
                        <li class="layui-nav-item">
                            <a href="javascript:;"><span class="layui-nav-more"></span></a>
                            <dl class="layui-nav-child">
                                <dd><a href="javascript:;" layuimini-tab-close="current">关 闭 当 前</a></dd>
                                <dd><a href="javascript:;" layuimini-tab-close="other">关 闭 其 他</a></dd>
                                <dd><a href="javascript:;" layuimini-tab-close="all">关 闭 全 部</a></dd>
                            </dl>
                        </li>
                    </ul>
                </li>
            </div>
            <div class="layui-tab-content">
                <div id="layuiminiHomeTabIframe" class="layui-tab-item layui-show"></div>
            </div>
        </div>

    </div>
</div>
<script>
    layui.use(['jquery', 'layer', 'miniAdmin','miniTongji'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            miniAdmin = layui.miniAdmin;

        var options = {
            iniUrl: "${baseUrl}menu.action",    // 初始化接口
            clearUrl: "${baseUrl}clear/clear.action", // 缓存清理接口
            urlHashLocation: true,      // 是否打开hash定位
            bgColorDefault: false,      // 主题默认配置
            multiModule: true,          // 是否开启多模块
            menuChildOpen: false,       // 是否默认展开菜单
            loadingTime: 0,             // 初始化加载时间
            pageAnim: true,             // iframe窗口动画
            maxTabNum: 20,              // 最大的tab打开数量
        };
        miniAdmin.render(options);



        $('.login-out').on("click", function () {
            logout("${baseUrl}",function (flag) {
                tip("退出登录成功");
                window.location.href = "${baseUrl}";
            });
        });

        $('.change-password').on("click",function () {
            openMiddleDialogByTagId("用户<${userVo.name}>修改密码",$("#changePasswordDialog"));
        });
    });
</script>
</body>

<div id="changePasswordDialog" class="myDialog">
    <form class="layui-form" action="" lay-filter="changePassword">
        <input type="hidden" name="id" value="${userVo.id}">

        <div class="layui-form-item">
            <label class="layui-form-label">原密码</label>
            <div class="layui-input-block">
                <input type="password" name="oldPassword" placeholder="原密码"  lay-verify="oldPassword" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" placeholder="新密码"  lay-verify="password" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="password" name="entryPassword" placeholder="确认密码"  lay-verify="entryPassword" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <a class="layui-btn" lay-submit lay-filter="save">保存</a>
                <a class="layui-btn layui-btn-primary" id="cancel">取消</a>
            </div>
        </div>
    </form>

    <script>
        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table;
            $("#cancel").click(function () {
                closeAll();
            });

            //自定义验证规则
            form.verify({
                oldPassword: [
                    /^[\S]{6,12}$/
                    ,'原密码必须6到12位，且不能出现空格'
                ]
                ,password: [
                    /^[\S]{6,12}$/
                    ,'新密码必须6到12位，且不能出现空格'
                ]
                ,entryPassword: function(value){
                    if(value.match(/^[\S]{6,12}$/) == null){
                        return '确认密码必须6到12位，且不能出现空格';
                    }
                    var password = $("[name='password']").val();
                    if (password != value) {
                        return '确认密码与新密码不一致';
                    }

                    var oldPassword = $("[name='oldPassword']").val();
                    if (oldPassword == value) {
                        return '原密码与新密码不能一样';
                    }
                }
            });

            form.on('submit(save)', function (data) {
                console.log(JSON.stringify(data.field));
                delete data.field.entryPassword;
                tipLoad("密码修改中");
                post("${baseUrl}user/user/changePassword.action", data.field,function (resp) {
                    closeAll();
                    if (resp.code == 1) {
                        $('.login-out').click();
                    } else {
                        errTip(resp.msg);
                    }
                });

                return false;
            });
        });
    </script>
</div>
<html:loading/>
